Class WebSocketServiceTest

java.lang.Object
com.fsf.news.service.WebSocketServiceTest

@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class) class WebSocketServiceTest extends Object
Unit tests for the WebSocketService class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) org.apache.pekko.actor.typed.ActorSystem<com.fsf.news.actor.websocket.message.WebSocketMessage>
     
    (package private) Duration
     
    (package private) org.apache.pekko.stream.javadsl.Flow<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode,org.apache.pekko.NotUsed>
     
    (package private) play.mvc.Http.RequestHeader
     
    (package private) play.libs.F.Either<play.mvc.Result,org.apache.pekko.stream.javadsl.Flow<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode,?>>
     
    (package private) org.apache.pekko.actor.typed.Scheduler
     
    (package private) com.fsf.news.service.WebSocketService
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Tests that connection method returns the expected Flow wrapped in Either.
    (package private) void
    Tests that sameOriginCheck returns true for allowed hosts.
    (package private) void
    Tests that sameOriginCheck returns false for disallowed hosts.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • service

      @InjectMocks com.fsf.news.service.WebSocketService service
    • actorSystem

      @Mock org.apache.pekko.actor.typed.ActorSystem<com.fsf.news.actor.websocket.message.WebSocketMessage> actorSystem
    • scheduler

      @Mock org.apache.pekko.actor.typed.Scheduler scheduler
    • duration

      @Mock Duration duration
    • request

      @Mock play.mvc.Http.RequestHeader request
    • flow

      @Mock org.apache.pekko.stream.javadsl.Flow<com.fasterxml.jackson.databind.JsonNode,com.fasterxml.jackson.databind.JsonNode,org.apache.pekko.NotUsed> flow
  • Constructor Details

    • WebSocketServiceTest

      WebSocketServiceTest()
  • Method Details

    • testSameOriginCheck

      @Test void testSameOriginCheck()
      Tests that sameOriginCheck returns true for allowed hosts.
    • testSameOriginCheckDifferent

      @Test void testSameOriginCheckDifferent()
      Tests that sameOriginCheck returns false for disallowed hosts.
    • testConnection

      @Test void testConnection()
      Tests that connection method returns the expected Flow wrapped in Either.